package com.ruoyi.tool;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class WfcTool {

    public static double bigToDoule(BigDecimal bigDecimal) {
        if (bigDecimal == null) {
            return 0;
        } else {
            return bigDecimal.doubleValue();
        }

    }

    public static double longToDoule(Long retLong) {
        if (retLong == null) {
            return 0;
        } else {
            return Double.valueOf(retLong);
        }

    }

    //2025年2月：1|六 2|日等
    public static List<String> getDaysAndWeek(int year, int month) {
        Map<String, String> cnWeeks = new HashMap<>();
        cnWeeks.put("SATURDAY", "六");
        cnWeeks.put("SUNDAY", "日");
        cnWeeks.put("MONDAY", "一");
        cnWeeks.put("TUESDAY", "二");
        cnWeeks.put("WEDNESDAY", "三");
        cnWeeks.put("THURSDAY", "四");
        cnWeeks.put("FRIDAY", "五");

        List<String> daysOfWeek = new ArrayList<>();
        YearMonth yearMonth = YearMonth.of(year, month);
        // 获取该月的第一天
        LocalDate firstDayOfMonth = yearMonth.atDay(1);
        // 获取该月的最后一天
        LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
        // 遍历这个月每一天，并获取星期几
        for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) {
            daysOfWeek.add(date.getDayOfMonth() + "日\n" + cnWeeks.get(String.valueOf(date.getDayOfWeek())));
        }

        return daysOfWeek;
    }
}
